import java.io.File;
import java.util.Scanner;

/*2. 编程题

        实现将指定目录中的所有内容删除，包含子目录中的内容都要全部删除。*/
public class Q2 {

    public static void deleteAll(File path) {
        for (File subpath:path.listFiles()) {
            if (subpath.isDirectory()) {
                System.out.println("进入执行删除目录"+subpath);
                deleteAll(subpath);
            }
            else {
                System.out.println("找到并删除文件：" + subpath);
            }
            subpath.delete();
        }
    }

    public static void main(String[] args) {
        System.out.println("请输入删除的文件夹名：");
        Scanner sc = new Scanner(System.in);
        String path = sc.next();
        File file = new File(path);
        if (!file.isDirectory()) {
            System.out.println("路径非目录，取消操作");
            return;
        }
        deleteAll(file);
    }
}
